var mysql      = require('mysql');
var connection = mysql.createConnection({
    host     : 'localhost',
    user     : 'root',
    password : '1234567',
    database : 'test'
});


//增加数据
connection.connect();

//每次输入一个opertion执行对应操作

///修改格式,id为查找，其他对应修改
//修改密码
//var modSql = 'update user SET UserPassword= ? WHERE Userid = ?';
//var modSqlParams = ['5555',4];

//修改购买物品
 modSql = 'update user SET UserItem= ?  WHERE Userid = ?';
 modSqlParams = ['ipad2020',4];

//修改地址
// modSql = 'update user SET UserAddress= ?  WHERE Userid = ?';
// modSqlParams = ['美国加利福尼亚',4];

connection.query(modSql,modSqlParams,function (err, result) {
    if(err){
        console.log('[UPDATE ERROR] - ',err.message);
        return;
    }
    console.log('--------------------------UPDATE----------------------------');
    console.log('UPDATE affectedRows',result.affectedRows);
    console.log('-----------------------------------------------------------------\n\n');
});


connection.end();
